<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="shortcut icon" href="/img/favicon.ico"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/common/layuimini/layui.css" media="all">
    <link rel="stylesheet" href="/common/layuimini/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label"><span style="color: red">*</span>任务名称</label>
        <div class="layui-input-block">
            <input type="text" name="jobName" lay-verify="required" lay-reqtext="任务名称为空" autocomplete="off" placeholder="请输入标题" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">任务分组</label>
        <div class="layui-input-block" id="jobGroup" name="jobGroup"></div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span style="color: red">*</span>调用目标</label>
        <div class="layui-input-block">
            <input type="text" name="invokeTarget" lay-verify="required" lay-reqtext="调用目标为空" autocomplete="off" placeholder="请输入标题" class="layui-input">
            <div class="layui-form-mid layui-word-aux">调用示例：com.blog.quartz.BlogTask.jobParams('niuma')</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span style="color: red">*</span>cron表达式</label>
        <div class="layui-input-block">
            <input type="text" name="cronExpression" lay-verify="required" lay-reqtext="cron表达式为空" autocomplete="off" placeholder="请输入标题" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">执行策略</label>
        <div class="layui-input-block">
            <input type="radio" name="misfirePolicy" value="1" title="立即执行" checked="">
            <input type="radio" name="misfirePolicy" value="2" title="执行一次">
            <input type="radio" name="misfirePolicy" value="3" title="放弃执行">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">并发执行</label>
        <div class="layui-input-block">
            <input type="radio" name="concurrent" value="1" title="允许">
            <input type="radio" name="concurrent" value="2" title="禁止" checked="">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="1" title="正常" checked="">
            <input type="radio" name="status" value="2" title="暂停">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">描述</label>
        <div class="layui-input-block">
            <textarea name="remark" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>

    <div class="layui-btn-container" style="float: right;">
        <button class="layui-btn layui-btn-primary layui-border-blue" style="border-radius: 20px;" lay-submit lay-filter="saveJob">保&nbsp;&nbsp;存</button>
        <button onclick="parent.layer.close(parent.layer.getFrameIndex(window.name))" class="layui-btn layui-btn-primary layui-border-red" style="border-radius: 20px;">取&nbsp;&nbsp;消</button>
    </div>

</div>
</body>
<script type="text/javascript" src="/common/layui/layui.js"></script>
<script type="text/javascript" src="/common/jquery-1.11.3.js"></script>
<script type="text/javascript" src="/common/xm-select/xm-select.js"></script>
<script type="text/javascript">

    window.onload = function () {
    }

    var demo1 = xmSelect.render({
        el: '#jobGroup',
        radio: true,
        clickClose: true, //点击之后关闭
        initValue: ['DEFAULT'],
        theme: {
            color: '#0081ff',
        },
        model: {
            icon: 'hidden',
            label: {
                type: 'text'
            }
        },
        data: [
            {name: '系统默认', value: 'DEFAULT'},
            {name: '用户定义', value: 'CUSTOMIZE'}
        ]
    })

    layui.use(['form'],function (){
        var form = layui.form;


        form.on('submit(saveJob)',function (obj){
            console.log("-0-0-0-0-0-0-0-0-0-0-0-");
            console.log(obj.field);
            $.ajax({
                type: "post",
                url: "/admin/job/saveJob",
                dataType: "json",
                data: {
                    "jobName":obj.field.jobName,
                    "jobGroup": demo1.getValue('valueStr'),
                    "invokeTarget": obj.field.invokeTarget,
                    "cronExpression": obj.field.cronExpression,
                    "misfirePolicy": obj.field.misfirePolicy,
                    "concurrent": obj.field.concurrent,
                    "status": obj.field.status,
                    "remark": obj.field.remark
                },
                success: function (res){
                    if (res.state){
                        layer.msg("操作成功",{icon:1,time:800})
                        parent.layer.close(parent.layer.getFrameIndex(window.name))
                        parent.layui.table.reload('currentTaskTable');
                    }else {
                        layer.msg("操作失败",{icon:2,time:800})
                    }
                }
            })
        })
    })
</script>
</html>